package com.his.controller;

import com.his.common.PageParam;
import com.his.common.Rsp;
import com.his.entity.Recipel;
import com.his.entity.RecipelChild;
import com.his.service.RecipelChildService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (RecipelChild)表控制层
 *
 * @author makejava
 * @since 2020-10-23 18:14:40
 */
@RestController
@RequestMapping("recipelChild")
public class RecipelChildController {
    /**
     * 服务对象
     */
    @Resource
    private RecipelChildService recipelChildService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @PostMapping("selectOne")
    public Rsp selectOne(Integer id) {
        return this.recipelChildService.queryById(id);
    }


    /**
     * 增加子处方
     */
    //@RequireRoles(roles = "medicinal",index = 0)
    @PostMapping("insertOne")
    public Rsp insertOne(@RequestBody RecipelChild recipelChild) {
        return this.recipelChildService.insert(recipelChild);
    }

    /*
     *删除子处方
     */
    @PostMapping("deleteByIdLogic")
    public Rsp deleteByIdLogic(@RequestBody RecipelChild recipelChild) {
        return recipelChildService.deleteByIdLogic(recipelChild.getId());
    }

    /*
     *删除子处方
     */
    @PostMapping("deleteOne")
    public Rsp deleteOne(@RequestBody RecipelChild recipelChild) {
        return recipelChildService.deleteById(recipelChild.getId());
    }

    /**
     * 修改子处方
     */
    @PostMapping("updateOne")
    public Rsp updateOne(@RequestBody RecipelChild recipelChild) {
        return recipelChildService.update(recipelChild);
    }

    /**
     * 查询子处方列表
     */
    @PostMapping("searchSomeRecipelPage")
    public Rsp searchSomeRecipelPage(@RequestBody PageParam<RecipelChild> pageParam) {
        return Rsp.success(recipelChildService.searchRecipelChildPage(pageParam));
    }

    /**
     * 根据主id查子处方
     */
    @PostMapping("searchRecipelChilds")
    public Rsp searchRecipelChilds(@RequestBody PageParam<RecipelChild> pageParam) {
        return Rsp.success(recipelChildService.searchRecipelChildPage(pageParam));
    }
}
